package com.quick.develop.flowable.framework.manager.identity;

import org.flowable.idm.api.User;
import org.flowable.idm.engine.IdmEngineConfiguration;
import org.flowable.idm.engine.impl.UserQueryImpl;
import org.flowable.idm.engine.impl.persistence.entity.UserEntity;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityManagerImpl;
import org.flowable.idm.engine.impl.persistence.entity.data.UserDataManager;

import java.util.Collections;
import java.util.List;

/**
 * @author junyuan.liu
 * @description: TODO 
 * @date 2022/6/24 10:53
 */
public class CustomUserEntityManager extends UserEntityManagerImpl {
    public CustomUserEntityManager(IdmEngineConfiguration idmEngineConfiguration, UserDataManager userDataManager) {
        super(idmEngineConfiguration, userDataManager);
    }

    @Override
    public UserEntity findById(String userId) {
        UserQueryImpl aUserQueryImpl = (UserQueryImpl) new UserQueryImpl().userId(userId);
        //查自己数据库数据
        UserEntity user = new UserEntityImpl();
        user.setId("admin");
        user.setDisplayName("ECM");
        user.setEmail("email");
        return user;
    }

    @Override
    public List<User> findUserByQueryCriteria(UserQueryImpl query) {
        User user = new UserEntityImpl();
        user.setId("admin");
        user.setDisplayName("ECM");
        user.setEmail("email");
        return Collections.singletonList(user);
    }

    @Override
    public long findUserCountByQueryCriteria(UserQueryImpl query) {
        return 1L;
    }
}
